package net.mobgame.network;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class Preference {
	private SharedPreferences mPrefs;

	private final String ACCESS_TOKEN = "access_token";
	private final String USER_INFO = "user_info";
	private final String USER_REGISTER_INFO = "user_register_info";
	private final String LIST_DATA_HOME = "list_data_home";

	private final String SO_LUONG_ANH_CHUP = "so_luong_anh_chup";
	private final String NOTIFICATION_GPS = "notification_gps";
	private final String ACCOUNT_POST_PHONE_NUMBER = "account_post_phone_number";
	//	private final String ACCOUNT_IDENTITY_INFORMATION = "account_identity_information";
	private final String IS_LOGIN = "login_user";

	public Preference(Context context) {
		mPrefs = context.getSharedPreferences("mobgame", 0);
	}

	public void setNotificationGPS(boolean notifi) {
		Editor editor = mPrefs.edit();
		editor.putBoolean(NOTIFICATION_GPS, notifi);
		editor.commit();
	}

	public boolean getNotificationGPS() {
		return mPrefs.getBoolean(NOTIFICATION_GPS, false);  
	}

	public void setAccountPostPhoneNumber(String infor) {
		Editor editor = mPrefs.edit();
		editor.putString(ACCOUNT_POST_PHONE_NUMBER, infor);
		editor.commit();
	}

	public String getAccountPostPhoneNumber() {
		return mPrefs.getString(ACCOUNT_POST_PHONE_NUMBER, null);
	}

	/**
	 * DAI
	 * @param keyOption
	 * @param valueOption
	 */
	public void setSoLuongAnh(String soLuongAnh) {
		Editor editor = mPrefs.edit();
		editor.putString(SO_LUONG_ANH_CHUP, soLuongAnh);
		editor.commit();
	}

	public String getSoLuongAnh() {
		return mPrefs.getString(SO_LUONG_ANH_CHUP, null);
	}

	/**
	 * END Dai
	 * @param keyOption
	 * @param valueOption
	 */
	/*
	 * khiemnd start
	 */
	public void setOptionSwitch(String keyOption, boolean valueOption) {
		Editor editor = mPrefs.edit();
		editor.putBoolean(keyOption, valueOption);
		editor.commit();
	}

	public boolean getOptionSwitch(String keyOption) {
		return mPrefs.getBoolean(keyOption, false);
	}

	// khiemnd end

	public void setAccessToken(String accessToken) {
		Editor editor = mPrefs.edit();
		editor.putString(ACCESS_TOKEN, accessToken);
		editor.commit();
	}

	public String getAccessToken() {
		return mPrefs.getString(ACCESS_TOKEN, null);
	}

	// luu thong tin ca nhan
	public void setUserInfo(String cusInfo) {
		Editor editor = mPrefs.edit();
		editor.putString(USER_INFO, cusInfo);
		editor.commit();
	}

	public String getUserInfo() {
		return mPrefs.getString(USER_INFO, null);
	}

	// luu trang da dang nhap chua?
	public void setLogin(boolean isLogin){
		Editor editor = mPrefs.edit();
		editor.putBoolean(IS_LOGIN, isLogin);
		editor.commit();
	}

	public boolean getLogin(){
		return mPrefs.getBoolean(IS_LOGIN, false);
	}

	public void setUserRegisterInfo(String cusResInfo) {
		Editor editor = mPrefs.edit();
		editor.putString(USER_REGISTER_INFO, cusResInfo);
		editor.commit();
	}

	public String getUserRegisterInfo() {
		return mPrefs.getString(USER_REGISTER_INFO, null);
	}

	// SAVE LIST DATA FOR SORT
	public String getListData() {
		return mPrefs.getString(LIST_DATA_HOME, null);
	}

	public void setListData(String list) {
		Editor editor = mPrefs.edit();
		editor.putString(LIST_DATA_HOME, list);
		editor.commit();
	}

}
